<?php

namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class ComposerServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        // 使用基于类的 composer...
        View::composer(
            'blade.show', 'App\Http\ViewComposers\ShowComposer'
        );

        // 使用基于闭包的 composers...
        View::composer('show', function ($view) {
           // $view->with('list', array('name'=>'test','avatar'=>'/path/to/test.jpg'));
        });
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
